import React, { Component } from 'react';
import { Toast } from 'antd-mobile';
import { Link } from 'react-router-dom';
//import './App.css';
import '../css/skin.css';
import '../css/client.css';


class App extends Component {
  constructor(props){
    super(props);
    this.state = {
      userCount:0,
      loanApplyCount:0
    }
  }

  componentDidMount() {
    // ajax get infos
    let _url = "http://58.220.10.23:8001/api/stat/queryNewUsersCountToday";
    fetch(_url,{ method: 'GET', credentials: 'include' })
    .then(response => response.json())
    .then(data=>{
       console.log(data);
       if( data.status===0 ){
         this.setState({userCount:data.userCount,loanApplyCount:data.loanApplyCount});
       }else{
         Toast.fail(data.msg, 1);
       }
    });
  }

  render() {
    return (
      <div className="skin-orange">
      	<p className="title">抢客户</p>
        <div className="client-wrap">
          <p className="client-title">今日新增贷款申请</p>
          <p className="text-color new-num">{this.state.loanApplyCount}</p>
          <p className="client-title">今日新增客户</p>
          <p className="text-color new-num" style={{margin: '0 0 1rem 0'}}>{this.state.userCount}</p>          
          <Link to="/companyList" className="bg-color btn-client white">抢客户</Link>
        </div>

      </div>

    );
  }
}

export default App;
